import {BpmnNode} from "/@/views/flow/design/component/property-panel/ts/node/BpmnNode";
import SequenceFlow from '../../../panel/SequenceFlow.vue'
/**
 * 连线节点
 */
export class SequenceFlowNode extends BpmnNode{
    private businessObject;
    private component;
    constructor() {
        super();
        this.component = SequenceFlow
    }

   async setProperties(e,object,moddle,modeling) {
        let obj = {} as any
        for (const key in object) {
            if(key.startsWith('_')){
                const conditionExpression = await moddle.create("bpmn:FormalExpression",{body: object[key]})
                obj.conditionExpression = conditionExpression
            }else{
                obj[key] = object[key]
            }
        }
        modeling.updateProperties(e.element,obj)
    }

    nodeClick(bpmnViewerValue: any, e: any) {
        this.businessObject = e.element.businessObject
        const modeling = bpmnViewerValue.get('modeling')
        const moddle = bpmnViewerValue.get("moddle")
        if(this.propertyPanelRef){
            this.propertyPanelRef.value.init(this.businessObject,this.component,async (object: any)=>{
                this.setProperties(e,object,moddle,modeling);
            })
        }
    }

    nodeChange(bpmnViewerValue: any, e: any) {
    }

    nodeCreate(bpmnViewerValue: any, e: any){

    }





}